//package com.example.book_recommend.filter;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.boot.web.servlet.ServletComponentScan;
//import org.springframework.core.Ordered;
//import org.springframework.core.annotation.Order;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.*;
//import javax.servlet.annotation.WebFilter;
//import javax.servlet.http.HttpServletRequest;
//import java.io.IOException;
//import java.util.Map;
//
//@Component
////用来扫描Servlet的过滤器，使@WebFilter生效
//@ServletComponentScan
////将类声明为一个过滤器，该注解将会在部署时被容器处理，容器将根据具体的属性配置将相应的类部署为过滤器
//@WebFilter(urlPatterns = "/login", filterName = "parameterFilter")
////配置过滤器的加载顺序，数值越低，表示优先级越高
//@Order(Ordered.HIGHEST_PRECEDENCE)
//public class ParameterTakeFilter implements Filter {
//
//    private FilterConfig filterConfig = null;
//
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//        this.filterConfig = filterConfig;
//    }
//
//    @Override
//    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
//        if (filterConfig == null)
//            return;
//        /*这里要注意不能用getReader()或者getInpustream()这种方法获取请求参数，
//        因为这两种方法是把缓冲区的数据流读取出来，数据流是只能读一次的，
//        一旦这里把流读取出来缓冲区被清空，Controller层的请求就拿不到参数了*/
//        /*BufferedReader reader = request.getReader();
//        String line;
//        StringBuffer sb = new StringBuffer();
//        while ((line = reader.readLine())!=null){
//            sb.append(line);
//        }*/
//        //从请求头中获取需要打印到日志中的post参数
//        String oaNo = ((HttpServletRequest) request).getParameter("bookId");
//        request.setAttribute("postdata", oaNo);
//        Map<String,String[]> m = request.getParameterMap();
////        System.out.print("out:"+m);
//
//        chain.doFilter(request, response);
//    }
//
//    @Override
//    public void destroy() {
//        this.filterConfig = null;
//    }
//}